package com.example.kaoshi;

import java.util.*;

/**
 * Created by Quincy on 2018/9/9.
 */
public class Test7 {


    public static int maxLenthNoRepeat(String str){
        if(str==null || str.isEmpty()){
            return 0;
        }
        Map<Character, Integer> map = new HashMap<Character, Integer>();
        int maxLength = 0;
        int current = 0;

        //循环字符串，取出每个字符
        for(int index=0; index < str.length(); index++){
            if(map.containsKey(str.charAt(index))){
                current = map.get(str.charAt(index)) + 1;
            }
            else{
                if((index-current+1)>maxLength){
                    maxLength=index-current+1;
                }
            }
            map.put(str.charAt(index), index);
        }

        return maxLength;
    }

    public static int lengthOfLongestSubstring(String s) {
        int n = s.length();
        Set<Character> set = new HashSet<>();
        int ans = 0, i = 0, j = 0;
        while (i < n && j < n) {
            // try to extend the range [i, j]
            if (!set.contains(s.charAt(j))){
                set.add(s.charAt(j++));
                ans = Math.max(ans, j - i);
            }
            else {
                set.remove(s.charAt(i++));
            }
        }
        return ans;
    }

    //main函数测试
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        String _str;
        _str = in.nextLine();

        System.out.println(lengthOfLongestSubstring(_str));

    }
}
